const defaultSettings = require('@/settings')

const { Title, FixedHeader, HiddenSideBar, Locale, Layout, Theme } = defaultSettings

const state = {
  title: Title,
  fixedHeader: FixedHeader,
  hiddenSideBar: HiddenSideBar,
  locale: Locale,
  layout: Layout,
  theme: Theme
}
const mutations = {
  CHANGE_SETTING({ key, value }) {
    // eslint-disable-next-line no-prototype-builtins
    if (this.hasOwnProperty(key)) {
      this[key] = value
    }
  }
}

const actions = {
  changeSetting(data) {
    this.CHANGE_SETTING(data)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
